<template>
  <div>
    <el-row>
      <el-col :span="12">
        <el-button type="success" @click="isdraw('新增')">新增</el-button>
        <el-button type="warning" @click="isdraw('修改')">修改</el-button>
        <el-button type="danger" @click="delonData">删除</el-button>
      </el-col>
      <el-col :span="12">
        <el-input placeholder="请输入内容" v-model="input" class="input-with-select">
          <el-select v-model="select" slot="prepend" style="width:130px" placeholder="请选择">
            <el-option label="餐厅名" value="1"></el-option>
            <el-option label="订单号" value="2"></el-option>
            <el-option label="用户电话" value="3"></el-option>
          </el-select>
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </el-col>
    </el-row>
    <div style="margin-top: 30px">
      <!--  -->
      <el-table
        :data="tableData"
        style="width: 100%"
        max-height="700"
        @selection-change="handleSelectionChange"
      >
        <el-table-column fixed type="selection" width="55"></el-table-column>
        <el-table-column type="index" width="50" label="#"></el-table-column>
        <el-table-column prop="name" label="姓名" width="120"></el-table-column>
        <el-table-column prop="age" label="年龄" width="120"></el-table-column>
        <el-table-column prop="gender" label="性别" width="120"></el-table-column>
        <el-table-column prop="loginName" label="用户名" width="300"></el-table-column>
        <el-table-column prop="loginKey" label="密码" width="120"></el-table-column>
        <el-table-column fixed="right" label="操作" width="120">
          <template slot-scope="scope">
            <el-button @click.native.prevent="deleteRow(scope.row,'删除')" type="text" size="small">移除</el-button>
            <el-button @click.native.prevent="deleteRow(scope.row,'修改')" type="text" size="small">修改</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!--  -->
    </div>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, sizes, prev, pager, next, jumper"
      :total="400"
    ></el-pagination>
    <el-drawer :title="title" :visible.sync="drawer" :before-close="handleClose">
      <div class="demo-drawer__content">
        <el-form :model="form">
          <el-form-item label="姓名" :label-width="formLabelWidth">
            <el-input v-model="form.name" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="年龄" :label-width="formLabelWidth">
            <el-input v-model="form.age" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="性别" :label-width="formLabelWidth">
            <el-radio-group v-model="form.gender">
              <el-radio label="男" value="男"></el-radio>
              <el-radio label="女" value="女"></el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="用户名" :label-width="formLabelWidth">
            <el-input v-model="form.loginName" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="密码" :label-width="formLabelWidth">
            <el-input v-model="form.loginKey" autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="图片" :label-width="formLabelWidth">
            <el-input v-model="form.avatar" autocomplete="off"></el-input>
          </el-form-item>
        </el-form>
        <div class="demo-drawer__footer">
          <el-button @click="qx">取 消</el-button>
          <el-button type="primary" @click="qd">确 定</el-button>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
export default {
  layout: "mine",
  data() {
    return {
      input: "",
      select: "",
      drawer: false,
      title: "新增",
      currentPage: 1,
      form: {},
      pageSize: 10,
    };
  },
  medthods: {
    qd() {
      console.log(123);
    },
    qx() {
      console.log(456);
    },
    handleSelectionChange(val) {
      // console.log(val);
      this.multipleSelection = val;
      console.log(this.multipleSelection);
    },
    deleteRow(row, v) {
      if (v == "删除") {
        this.delUser([row.id]);
      } else {
        this.isdraw(v, row);
      }
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      this.currentPage = val;
    }
  }
};
</script>

<style scoped>
</style>